#include "EWAUITrackScrollContentLayout.hpp"

namespace Eyer
{
    int EWAUITrackScrollContentLayout::OnDraw()
    {
        EWAUILayout::OnDraw();
        return 0;
    }

    bool EWAUITrackScrollContentLayout::OnMouseMoveEvent (const Vec2I & pos)
    {
        if(horizontalSegBar->IsDraging()){
            // 拖拽
            trackHeader->SetTrackHeaderWidth(pos.x() - 0);
        }
        return true;
    }

    EWAUITrackScrollContentLayout::EWAUITrackScrollContentLayout(EyerSmartPtr<EWAUITimelineContext> _timelineCtx, EWAUILayoutParams width, EWAUILayoutParams height)
        : EWAUILayout(EWAUILayoutType::LinearLayoutHorizontal, width, height)
        , timelineCtx(_timelineCtx)
        , trackHeader(new EWAUITrackHeader(timelineCtx, LP::WRAP_CONTENT, LP::WRAP_CONTENT))
        , trackBodyScroll(new EWAUIWidgetScroll(ScrollType::HORIZONTAL, LT::LinearLayoutHorizontal, LP::WRAP_CONTENT, LP::MATCH_PARENT))
        , horizontalSegBar(new EWAUIWidgetHorizontalSegBar(LP::WRAP_CONTENT, LP::MATCH_PARENT))
    {
        SetBGColor(EyerColor::GRAY);
        SetWidgetName("EWAUITrackScrollContentLayout");
        AddWidget(trackHeader);
        AddWidget(horizontalSegBar);
        AddWidget(trackBodyScroll);
        trackBodyScroll->SetWidgetName("EWAUITrackBodyScroll");

        EyerSmartPtr<EWAUITrackBody> trackBody(new EWAUITrackBody(timelineCtx, LP::WRAP_CONTENT, LP::WRAP_CONTENT));
        trackBodyScroll->AddContentWidget(trackBody);
    }

    EWAUITrackScrollContentLayout::~EWAUITrackScrollContentLayout()
    {

    }
}